/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var DAMAGE = {
    buffer: "",
    ctx: "",
    
    queue: "",
    
    Init: function() {
        this.buffer = document.createElement("canvas");
        this.buffer.height = 480;
        this.buffer.width = 1024;
        
        this.ctx = this.buffer.getContext("2d");
        this.queue = new Array();
    },
    
    Update: function() {
        var i=0;
        if (i < this.queue.length) {
            if (this.queue[i][3] > 0) {
                i++;
            } else {
                this.queue.splice(i, 1);
            }
        }
    },
    
    Draw: function(ctx) {
        this.ctx.clearRect(0,0,this.buffer.width,this.buffer.height);
        this.ctx.fillStyle = "red";
        for (var i=0; i<this.queue.length; i++) {
            this.ctx.fillText(this.queue[i][2], this.queue[i][0], HEIGHT-FLOOR-this.queue[i][1]);
            this.queue[i][1]++;
            this.queue[i][3]--;
        }
        ctx.drawImage(this.buffer, 0, 0, 1024, 480);
    },
    
    Add: function(p, t) {
        this.queue.push([p.pos.X, p.size, t, 30]);
    }
}

